<template>
  <div class="page-login">
    <LoginHeader>欢迎登录</LoginHeader>
    <section class="login-section">
      <div class="wrapper">
        <nav>
          <a href="javascript:;" @click="activeName='account'" :class="{active:activeName==='account'}">账户登录</a>
          <a href="javascript:;" @click="activeName='qrcode'" :class="{active:activeName==='qrcode'}">扫码登录</a>
        </nav>
        <!-- 账号登录与扫码登录 -->
        <!-- 表单 -->
        <LoginForm v-if="activeName==='account'"></LoginForm>
        <!-- 二维码 -->
        <div v-if="activeName==='qrcode'" class="qrcode-box">
          <img src="../../assets/images/qrcode.jpg" alt="">
          <p>打开<a href="javascript:;">小兔鲜App</a>扫码登录</p>
        </div>
      </div>
    </section>
    <LoginFooter></LoginFooter>
  </div>
</template>
<script>
import LoginHeader from '@/views/login/component/login-header.vue'
import LoginFooter from '@/views/login/component/login-footer.vue'
import LoginForm from '@/views/login/component/login-form.vue'
import { ref } from 'vue'
import { useStore } from 'vuex'
import { useRoute } from 'vue-router'
export default {
  name: 'PageLogin',
  components: { LoginHeader, LoginFooter, LoginForm },
  setup () {
    const activeName = ref('account')
    // 存储回跳地址（将此时浏览器的地址保存在vuex中）
    const store = useStore()
    const route = useRoute()
    store.commit('user/setRedirectUrl', route.query.redirectUrl || '/')
    return { activeName }
  }
}
</script>

<style lang="less" scoped>
.login-section{
  background: url(../../assets/images/login-bg.png) no-repeat center/cover;
  height: 488px;
  position: relative;
  .wrapper{
    position: absolute;
    width: 380px;
    background-color: #fff;
    min-height: 400px;
    left: 50%;
    transform: translate3d(100px,0,0);
    top:54px;
    box-shadow:0 0 10px rgba(0,0,0,.15);
    nav {
      height:55px;
      border-bottom:1px solid #f5f5f5;
      display:flex;
      padding:0 40px;
      text-align: right;
      align-items: center;
      a{
        flex:1;
        line-height: 1;
        display: inline-block;
        font-size: 18px;
        position: relative;
        &:first-child{
          border-right: 1px solid #f5f5f5;
          text-align: left;
        }
        &.active{
          color: @xtxColor;
          font-weight: bold;
        }
      }
    }
  }
}
.qrcode-box{
  text-align: center;
  padding-top: 40px;
  p{
    margin-top: 20px;
    a{
      color:@xtxColor;
      font-size: 16px;
    }
  }
}
</style>
